#pragma once

#include <list>
using namespace std;
class Block;

class ISpace
{
public:
	//virtual Block* getFood() = 0;
	virtual void snakerOver() = 0;
	//virtual void createFood() = 0;
};

class Snaker
{
public:
	Snaker(ISpace* pSpace);
	~Snaker();

	enum DIRECTION { UP, DOWN, LEFT, RIGHT};

	void draw(CDC * pDC);
	void go();
	bool eat(Block* block);
	void changeDirection(DIRECTION dirction);
	void setRect(CRect rect) { this->rect = rect; }
	bool inTheBody(Block* pblock);
	void init();
private:
	list<Block*> body;
	Block* food;
	DIRECTION dirction;
	DIRECTION dirction_temp;
	ISpace* pSpace;
	CRect rect;
	void createFood();
	bool CollisionCheck();
	bool directiionTest(DIRECTION dirction);
};


class Block
{
public:
	Block(int _x, int _y)
	{
		this->x = _x;
		this->y = _y;
	}
	int x;
	int y;
};